package lucene.server.cdc.client;


import lucene.server.common.event.EventData;
import lucene.server.common.queue.ChangeProcessor;
import lucene.server.database.pool.PoolManager;

import java.util.*;

/**
 * @author jinji
 */
public abstract class AbstractClient  {

    protected String name;
    protected Properties properties;
    protected Filter filter;
    public AbstractClient(Properties properties) {
        if (properties == null || properties.isEmpty() || !properties.containsKey("name")){
            throw new RuntimeException("properties.name is required");
        }
        this.properties = properties;
        this.name = properties.getProperty("name");
        PoolManager.createConnection(this.properties);
        this.filter = new Filter(properties);
    }
    private static int count = 0;
    public void process(List<EventData> eventDataList) {
        ChangeProcessor.process(eventDataList);
    }

    public abstract void start();
    public abstract void shutdown();
    public abstract boolean isRunning();
    public abstract void reStart();

}